#include<signal.h>
#include<iostream>
#include<unistd.h>

using namespace std;


void myhandle(int signum)
{
    cout<<"get a signal num: "<<signum<<endl;
    exit(1);
}

// int main()
// {
//     signal(SIGFPE, myhandle);

//     cout<<"div before:"<<endl;
//     sleep(1);
//     int a = 1;
//     a /= 0;
//     cout<<"div before:"<<endl;
//     sleep(1);
//     return 0;
// }
int main()
{
    signal(SIGFPE, myhandle);

    cout<<"point error before:"<<endl;
    sleep(1);
    int *p = nullptr;
    *p = 100;
    cout<<"point error before:"<<endl;
    sleep(1);
    return 0;
}